# 最初的b2批次文件（1539个），含有和b1重复的
import os


def read_file_to_list(filename):
    result = []
    with open(filename, "r") as f:
        for line in f:
            result.append(line.strip())
    return result


# directory = "E:/data/palm_vein/SCUT-PV-V2/b2"
directory = "E:/data/palm_vein/SCUT-PV-V2/b2_roi"
filename = 'b2.txt'
file_set = set(read_file_to_list(filename))

for item in os.listdir(directory):
    if item in file_set:
        continue
    else:
        os.remove(os.path.join(directory, item))
